<div xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component">
	<f:loadBundle
	basename="eu.smoothit.sis.admin.util.msg_bundle" var="msgBundle" />
<!--	searching part-->
	 <ice:panelGrid
	columns="2" 
	rendered="#{!(empty logBean.dataList &amp;&amp; !logBean.searchMode)}">
	<ice:outputLabel for="userListBox" value="User" />

	<ice:selectOneMenu id="userListBox"
		value="#{logBean.searchExample.username}"
		rendered="#{!(empty logBean.allusers &amp;&amp; !logBean.searchMode)}">
		<f:selectItems value="#{logBean.allusers}" />
	</ice:selectOneMenu>

	<ice:outputLabel for="event" value="Event" />
	<ice:inputText id="event" value="#{logBean.searchExample.event}"
		disabled="#{logBean.editMode}"  
		label="event" />
	<ice:outputLabel for="result" value="Result" />
	<ice:inputText id="result" value="#{logBean.searchExample.result}"
		disabled="#{logBean.editMode}"  
		label="Result" />
	<ice:panelGroup>
		<ice:commandButton id="searchLog" value="#{msgBundle.buttonSearch}"
			action="#{logBean.actionSearch}"  />
	</ice:panelGroup>
	
<ice:selectOneRadio value="#{logBean.searchMethodTag}" partialSubmit="true" disabled="true">
		<f:selectItem itemValue="datePicker" itemLabel="     Picker"  />
		<f:selectItem itemValue="lastNdays" itemLabel  ="Last X days" />
</ice:selectOneRadio>
	<ice:outputLabel value="From"/>
	<ice:inputText value="#{logBean.selectDate_from}" valueChangeListener="#{logBean.dateSelectionValueChangeListener_from }" />
	<ice:outputLabel value="To"/>
	<ice:inputText value="#{logBean.selectDate_to}"  valueChangeListener="#{logBean.dateSelectionValueChangeListener_to }"/>
	<ice:selectOneMenu id="LastNdaysList" value="0">
	<f:selectItem itemValue="0" itemLabel="      " />
		<f:selectItem itemValue="-7" itemLabel="Last 7 days" />
		<f:selectItem itemValue="-14" itemLabel="Last 2 Weeks" />
		<f:selectItem itemValue="-30" itemLabel="Last 30 days" />
	</ice:selectOneMenu>
	<ice:commandButton actionListener="#{logBean.searchByDate}"
		value="Search" />
	</ice:panelGrid>
<!--		display table part-->
	<ice:dataTable id="tableLog" binding="#{logBean.dataTable}"
		value="#{logBean.dataList}" var="dataItem"
		rendered="#{!empty logBean.dataList}">
		<f:facet name="header">
			<ice:outputText value="Log Viewer" />
		</f:facet>
		<ice:column>
			<f:facet name="header">
				<ice:panelGroup>
					<ice:commandLink actionListener="#{logBean.actionSort}"
						disabled="#{logBean.editMode}" title="Sort on ID">
						<f:attribute name="sortField" value="id" />
						<ice:outputText value="ID" />
					</ice:commandLink>
					<ice:outputText value="&#0160;&#9650;" escape="false"
						rendered="#{logBean.sortField == 'id' &amp;&amp; !logBean.sortAscending}" />
					<ice:outputText value="&#0160;&#9660;" escape="false"
						rendered="#{logBean.sortField == 'id' &amp;&amp; logBean.sortAscending}" />
				</ice:panelGroup>
			</f:facet>
			<ice:outputText value="#{dataItem.id}"
				rendered="#{!empty dataItem.id}" />
			<ice:outputText value="new" rendered="#{empty dataItem.id}"
				styleClass="italic" />
		</ice:column>

		<ice:column>
			<f:facet name="header">
				<ice:panelGroup>
					<ice:commandLink actionListener="#{logBean.actionSort}"
						disabled="#{logBean.editMode}" title="Sort on user name">
						<f:attribute name="sortField" value="username" />
						<ice:outputText value="User" />
					</ice:commandLink>
					<ice:outputText value="&#0160;&#9650;" escape="false"
						rendered="#{logBean.sortField == 'username' &amp;&amp; !logBean.sortAscending}" />
					<ice:outputText value="&#0160;&#9660;" escape="false"
						rendered="#{logBean.sortField == 'username' &amp;&amp; logBean.sortAscending}" />
				</ice:panelGroup>
			</f:facet>
			<ice:outputText value="#{dataItem.username}"
				rendered="#{!logBean.editModeRow}" />
			<ice:inputText id="username" value="#{dataItem.username}"
				rendered="#{logBean.editModeRow}"
				label="Row ##{logBean.dataTable.rowIndex + 1} Name"
				required="#{!empty param['crud:table:save']}" 
				 />
		</ice:column>

		<ice:column>
			<f:facet name="header">
				<ice:panelGroup>
					<ice:commandLink actionListener="#{logBean.actionSort}"
						disabled="#{logBean.editMode}" title="sort on Event">
						<f:attribute name="sortField" value="event" />
						<ice:outputText value="Event" />
					</ice:commandLink>
					<ice:outputText value="&#0160;&#9650;" escape="false"
						rendered="#{logBean.sortField == 'event' &amp;&amp; !logBean.sortAscending}" />
					<ice:outputText value="&#0160;&#9660;" escape="false"
						rendered="#{logBean.sortField == 'event' &amp;&amp; logBean.sortAscending}" />
				</ice:panelGroup>
			</f:facet>
			<ice:outputText value="#{dataItem.event}"
				rendered="#{!logBean.editModeRow}" />
			<ice:inputText value="#{dataItem.event}"
				rendered="#{logBean.editModeRow}"
				label="Row ##{logBean.dataTable.rowIndex + 1} Value"
				required="#{!empty param['crud:table:save']}" />
		</ice:column>
		<ice:column>
			<f:facet name="header">
				<ice:panelGroup>
					<ice:commandLink actionListener="#{logBean.actionSort}"
						disabled="#{logBean.editMode}" title="sort on result">
						<f:attribute name="sortField" value="result" />
						<ice:outputText value="Result" />
					</ice:commandLink>
					<ice:outputText value="&#0160;&#9650;" escape="false"
						rendered="#{logBean.sortField == 'result' &amp;&amp; !logBean.sortAscending}" />
					<ice:outputText value="&#0160;&#9660;" escape="false"
						rendered="#{logBean.sortField == 'result' &amp;&amp; logBean.sortAscending}" />
				</ice:panelGroup>
			</f:facet>
			<ice:outputText value="#{dataItem.result}" />
		</ice:column>

		<ice:column>
			<f:facet name="header">
				<ice:panelGroup>
					<ice:commandLink actionListener="#{logBean.actionSort}"
						title="Sort by Date">
						<f:attribute name="sortField" value="date" />
						<ice:outputText value="Date" />
					</ice:commandLink>
					<ice:outputText value="&#0160;&#9650;" escape="false"
						rendered="#{logBean.sortField == 'date' &amp;&amp; !logBean.sortAscending}" />
					<ice:outputText value="&#0160;&#9660;" escape="false"
						rendered="#{logBean.sortField == 'date' &amp;&amp; logBean.sortAscending}" />
				</ice:panelGroup>
			</f:facet>
			<ice:outputText value="#{dataItem.date}" />
		</ice:column>
 <f:facet name="footer">
	<ice:panelGrid columns="4">

		<ice:panelGroup>
			<ice:inputText value="#{logBean.dataTable.rows}"
				label="#{msgBundle.labelRowsPage}"  size="1">
				<f:validateLongRange minimum="1" maximum="100" />
			</ice:inputText>
			<ice:commandButton value="#{msgBundle.buttonSet}"
				action="#{logBean.pageFirst}"  />
		</ice:panelGroup>
		<ice:outputText value="#{msgBundle.labelPaging}:" />
		<ice:panelGroup>
			<ice:commandButton value="#{msgBundle.buttonFirst}"
				action="#{logBean.pageFirst}" 
				disabled="#{logBean.dataTable.first == 0}" />
			<ice:commandButton value="#{msgBundle.buttonPrevious}"
				action="#{logBean.pagePrevious}" 
				disabled="#{logBean.dataTable.first == 0}" />
			<ice:commandButton value="#{msgBundle.buttonNext}"
				action="#{logBean.pageNext}" 
				disabled="#{logBean.dataTable.first + logBean.dataTable.rows >= logBean.dataTable.rowCount}" />
			<ice:commandButton value="#{msgBundle.buttonLast}"
				action="#{logBean.pageLast}" 
				disabled="#{logBean.dataTable.first + logBean.dataTable.rows >= logBean.dataTable.rowCount}" />
			<ice:outputText
				value="#{msgBundle.labelPage}: #{logBean.currentPage} / #{logBean.totalPages}" />
		</ice:panelGroup>
		<ice:panelGroup>
			<ice:commandButton value="#{msgBundle.buttonRefresh}"
				action="#{logBean.actionRefresh}" immediate="true"/>
		</ice:panelGroup>
	</ice:panelGrid>
</f:facet> 
</ice:dataTable>
<!-- this part only show when return empty search result-->
 <ice:panelGroup
	rendered="#{empty logBean.dataList &amp;&amp; !logBean.message}">
	<ice:panelGroup rendered="#{!logBean.searchMode}">
		<ice:outputText value="#{msgBundle.textNoData}" />
		<ice:commandButton value="#{msgBundle.buttonAdd}"
			action="#{logBean.actionAdd}"  />
	</ice:panelGroup>
	<ice:outputText value="Search"
		rendered="#{logBean.searchMode}" />
	<ice:commandButton value="#{msgBundle.buttonReset}"
		action="#{logBean.actionRefresh}"  />
</ice:panelGroup>

</div>
